Skip to content

fix(@clack/core): keyboard input not working after await in spinner#182

Merged
natemoo-re merged 1 commit into
bombshell-dev:mainfrom
orochaa:fix-post-spinner
Feb 21, 2024
Merged

fix(@clack/core): keyboard input not working after await in spinner#182
natemoo-re merged 1 commit into
bombshell-dev:mainfrom
orochaa:fix-post-spinner

Conversation

@orochaa

@orochaa orochaa commented Dec 14, 2023

Copy link
Copy Markdown
Contributor

Fix #176

Description

The issue occurred on Windows, when the await line between the spinner start and stop was present, causing the second following prompt to be unresponsive to key inputs (e.g., arrow keys or Ctrl-C), except for the [Enter] key. Additionally, this resulted in the duplication of the first option.

Solution

The solution is identify when it is running on Windows and do not change terminal's mode

if (input.isTTY && !isWindows) input.setRawMode(false);

Tested Environment:

OS: Windows, Ubuntu
Node Version: v18.17.1
Package: @clack/prompts
Package Version: v0.7.0

Snippet to Reproduce

const sp = p.spinner();
sp.start("start");
await setTimeout(2000);
sp.stop("stop");

const y = await p.confirm({
  message: "Test anyway?",
});

const x = await p.multiselect({
  message: "test",
  options: [
    { value: "a", label: "A", hint: "hint A" },
    { value: "b", label: "B", hint: "hint B" },
    { value: "c", label: "C", hint: "hint C" },
  ],
  required: false,
});

@changeset-bot

changeset-bot Bot commented Dec 14, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a04e418

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/core Patch
@clack/prompts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lucas-zimerman

lucas-zimerman commented Dec 14, 2023

Copy link
Copy Markdown

that indeed fixes the issues, I just wonder why it only affects the second call

@lucas-zimerman

Copy link
Copy Markdown

We actually don't need input.setRawMode
The thing is that clear here is being used for two flows (exiting the program if ctrl-c is pressed and clearing the line) instead of one (clearing the line).

On linux, SIGINT should be triggered so we can hook to it (I'll have to check it)

I'll add my suggestions on separated lines so that it can be marked as solved if implemented or discuss specifics parts of the suggestion.

@Lms24

Lms24 commented Jan 22, 2024

Copy link
Copy Markdown

Hey @natemoo-re friendly bump: any chance this PR could get reviewed and merged in?

@natemoo-re natemoo-re left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix and thanks for your patience!

@rorry121

rorry121 commented Jul 2, 2024

Copy link
Copy Markdown

Any news?When will a new version be released? @natemoo-re

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Keyboard input not working after await in spinner

5 participants